<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width, initial-scale=1.0">
    <title>Document</title>
    <style>
        /*class，类选择器*/
        .ji {
            color: red;
        }

        /*id选择器*/
        #hui {
            color: red;
            font-style: italic;
        }

        /*标签选择器*/
        div {
            font-size: 200px;
        }

        /*组合选择器*/
        /*后代选择器*/
        .done li {
            color: green;
            text-decoration: line-through;
        }

        .todo li {
            width: 200px;
            height: 35px;
            position: relative;
        }

        /*.todo li button{
             float: right;
         }*/
        .todo li button {
            /*绝对定位：会以第一个不是默认定位得父元素为原点进行定位*/
            position: absolute;
            top: 0;
            right: 0;
        }
    </style>
</head>

<body>
    <input type="text" id="input" placeholder="请输入充值金额">
    <button onclick="charge()">充值</button>
    <hr>
    <p>更改数组</p>
    <button onclick="add()">向数组尾部添加内容</button>
    <button onclick="del()">从数组尾部删除</button>
    <button onclick="shift()">从数组头部删除</button>
    <button onclick="unshift()">从数组头部添加</button>
    <hr>

    <hr>
    <script>
        /*声明函数*/
        function charge() {
            // let money=document.getElementById('input').value;
            let money = input.value;
            // console.log(document.getElementById('input').value);
            if (money >= 100) {
                alert('充值成功！充值金额：￥' + money + '元')
            }
            else {
                alert('100起充')
            }
        }
        let arr1 = [1, 2, 3, 4, 'wu', true];
        console.log(arr1);
        let person = {
            name: 'vutal',
            age: 24,
            isRich: false
        }
        let age = 'name';
        console.log(person.name);
        console.log(person['age']);
        console.log(person[age]);
        //点击按钮，给数组添加内容
        function add() {
            arr1.push('我是最后一项');
            console.log(arr1);
        }
        function del() {
            arr1.pop();
            console.log(arr1);
        }
        function shift() {
            arr1.shift();
            console.log(arr1);
        }
        function unshift() {
            arr1.unshift('1');
            console.log(arr1);
        }
    </script>
</body>

</html>